
clear
use "./dyad_1.dta"

joinby parliament using ./dyad_2
drop if placeonlist_1 >= placeonlist_2
sort parliament placeonlist_1 placeonlist_2 
order parliament placeonlist_1 placeonlist_2 id_1 candidate_name_1 id_2 candidate_name_2
label define support_lab 0 "not seconded" 1 "seconded"

rename id_1 id 
rename bill_2 bill
rename motion_2 motion 
merge m:1 parliament id bill motion using ./seconder_merge_rhs_rev
drop if _merge == 2
rename _merge support_1
recode support_1 1=0 3=1
label values support_1 support_lab
rename id id_1 
rename bill bill_2 
rename motion motion_2 

rename id_2 id 
rename bill_1 bill
rename motion_1 motion 
merge m:1 parliament id bill motion using ./seconder_merge_rhs_rev
drop if _merge == 2
rename _merge support_2
recode support_2 1=0 3=1
label values support_2 support_lab
rename id id_2 
rename bill bill_1
rename motion motion_1
drop num

gen support_category = 0
replace support_category = 1 if support_1 == 1 & support_2 == 0
replace support_category = 2 if support_1 == 0 & support_2 == 1
replace support_category = 3 if support_1 == 1 & support_2 == 1
label define support_category_lab 0 "no seconds" 1 "1 seconds 2" 2 "2 seconds 1" 3 "mutual seconds"
label values support_category support_category_lab

gen support_level = support_1 + support_2

gen p2p_level = p2p_1 + p2p_2 

gen same_party = (party_major_group_1 == party_major_group_2)

gen dyad_weight = . 
replace dyad_weight = 1 if same_party
replace dyad_weight = .5 if !same_party

gen distance = placeonlist_2 - placeonlist_1 - 1
*Rescale from 0 to 1
bysort parliament: egen max_distance = max(placeonlist_2)
replace max_distance = max_distance - 2
replace distance = distance / max_distance


*Table 2: Number of Seconds among Dyads where At Least One MP has the Power to Propose
tab support_level if p2p_level > 0


*Table 3: Dyadic Seconding, by Party
*Note the table is organized differently in the text, but it is the same data
tab party_major_group_1 party_major_group_2 if support_level >0 & p2p_level > 0


*Table B.6: Prevalence of seconding among all dyads
tab support_level 





